/**
*	JS 工具类
**/
var util = function(){
	var version = "1.0";
	$.fn.serializeObject = function() {
		var o = {};
		var a = this.serializeArray();
		$.each(a, function() {
			if (o[this.name] !== undefined) {
				if (!o[this.name].push) {
					o[this.name] = [o[this.name]];
				}
				o[this.name].push(this.value || '');
			} else {
				o[this.name] = this.value || '';
			}
		});
		return JSON.stringify(o);
	};
	return {
		getTemplateData : function(template){
			var key = "template_" + template + "_v_" + version;
			var catchData = store.get(key);
			
			if(typeof(catchData) == "undefined"){
				var url = "./../assets/scripts/template/" + template;
				$.ajax({
					url : url,
					type : "POST",
					async : false,
					success : function(obj,data,res){
						var templateData = res.responseText;
						catchData = templateData;
				        store.set(key,templateData);
					}
				});
			}
			
			return catchData;
		} ,
		showMessage : function(msg,messageType){
			toastr.options = {
			  "closeButton": true,
			  "debug": false,
			  "positionClass": "toast-top-right",
			  "onclick": null,
			  "showDuration": "300",
			  "hideDuration": "1000",
			  "timeOut": "5000",
			  "extendedTimeOut": "1000",
			  "showEasing": "swing",
			  "hideEasing": "linear",
			  "showMethod": "fadeIn",
			  "hideMethod": "fadeOut"
			}
			if(messageType){
				if(messageType == "success"){
					toastr.success(msg);
				}else if(messageType == "info"){
					toastr.info(msg);
				}else if(messageType == "warning"){
					toastr.warning(msg);
				}else if(messageType == "error"){
					toastr.error(msg);
				}else{
					toastr.info(msg);
				}
			}else{
				toastr.success(msg);
			}
		}
	}
}();